package net.sx.minemodule.mvp.activities;

import android.content.DialogInterface;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.homegoods.aroutercomment.ARouterPath;
import com.kedll.library.base.KRefreshListActivity;
import com.kedll.library.dialog.ECAlertDialog;
import com.kedll.library.listener.OnClickListener;

import net.sx.minemodule.R;
import net.sx.minemodule.databinding.MineActivityMineIntegralRecordingBinding;
import net.sx.minemodule.mvp.presenters.MineIntegralRecordPresenter;

/**
 * add shibo.zheng
 * 19/06/14
 * 历史积分记录界面
 */
@Route(path = ARouterPath.PATH_INTEGRAL_RECORD)
public class MineIntegralRecordingActivity extends KRefreshListActivity<MineActivityMineIntegralRecordingBinding, MineIntegralRecordPresenter> {
    @Autowired(name = "integralType")
    public String integralType;

    @Override
    protected int getLayout() {
        return R.layout.mine_activity_mine_integral_recording;
    }

    @Override
    protected MineIntegralRecordPresenter getPresenter() {
        return new MineIntegralRecordPresenter(this);
    }

    @Override
    protected void initEvent() {
        super.initEvent();
    }

    @Override
    protected void initToolBar(Bundle savedInstanceState) {
        super.initToolBar(savedInstanceState);
        ARouter.getInstance().inject(this);
        Log.d(TAG, "initToolBar: integralType == " + integralType);
        if (!TextUtils.isEmpty(integralType)){
            if ("expiredIntegral".equals(integralType)) {
                setTitle("30天内过期积分");
            } else if ("integralRecording".equals(integralType)) {
                setTitle("历史积分记录");
            } else if ("integralInfo".equals(integralType)) {
                setTitle("积分明细");
                setTopRightButton("积分说明", 0, new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ECAlertDialog dialog = ECAlertDialog.buildAlert(MineIntegralRecordingActivity.this,
                                "消费者购买商品后，“完成交易”+“完成评 论”后，才可以获得积分。\n\n" +
                                        "完成交易：签收后7天之内，无退款退货、退款的行为。\n\n" +
                                        "显示时间：付款时间、售后完成时间。\n\n", "取消", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog1, int which) {

                                    }
                                });
                        dialog.setTitle("");                                                //设置无标题
                        dialog.setMesGravity(Gravity.LEFT);                                 //设置文本居左显示
                        dialog.setContentPadding(10, 20, 10, 20);     //设置边距距离
                        dialog.show();
                    }
                });
            }
        }
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        ARouter.getInstance().inject(this);
        Log.d(TAG, "initData: integralType == " + integralType);
        if (!TextUtils.isEmpty(integralType)){
            mPresenter.setRecordDataType(integralType);
        }
    }
}
